package com.zat.mes.andrmes.dofun.work.adapter

import android.text.TextUtils
import android.view.LayoutInflater
import android.view.View
import android.widget.ImageView
import android.widget.LinearLayout
import androidx.core.content.ContextCompat
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.zat.mes.andrmes.R
 import com.zat.mes.andrmes.data.ProgramSchedulingBean
 import com.zat.mes.andrmes.data.ProgramSchedulingDetail
import com.zat.mes.andrmes.utils.SpannableStrUtil
import kotlinx.android.synthetic.main.fragment_day_produce_plan.*
import kotlinx.android.synthetic.main.item_item_proc_day_produce_plan.view.*

/**
 * @author xyan
 * @date :2023-07-19
 * @description:
 */
class DayProducePlanAndMaterialUsedAdapter(layoutResId: Int) :
    BaseQuickAdapter<ProgramSchedulingBean, BaseViewHolder>(layoutResId) {


    override fun convert(helper: BaseViewHolder, item: ProgramSchedulingBean) {

        helper.setText(R.id.morningEmpNameTV, "白班人员: "+item?.morningEmpName)
        helper.setText(R.id.nightEmpNameTV, if(item?.nightEmpName!=null)"晚班人员: "+item?.nightEmpName else "")
        helper.setText(R.id.monthPlanNoTV,"计划号:"+item.monthPlanNo).setText(R.id.colorTV,"颜色:"+item.color).setText(R.id.sizeTV,"尺码:"+item.size).setText(R.id.qtyTV,"数量:"+item.qty);
        helper.setText(R.id.orderNoTV,"订单号:"+item.orderNo).setText(R.id.machineNameTV,"机台号:"+item.machineName)
        var dataRV=helper.getView<RecyclerView>(R.id.dataRV);

        dataRV.layoutManager = LinearLayoutManager(context)
        var adapter=DayProducePlanAndMaterialUsedWLAdapter(R.layout.item_fragment_day_produce_plan_material_used_wl)
        dataRV.adapter = adapter
        adapter.setNewInstance(item.detailList as MutableList<ProgramSchedulingDetail> )




//        helper.setText(R.id.tvNameDayPlayItem, item?.styleName)
//            .setText(R.id.tvDateDayPlayItem, item?.planDayDate)
//        var styleNo = context.getString(R.string.text_style) + " " + item?.styleNo
//        var color = context.getString(R.string.text_color) + " " + item?.color
//        var machineNo = context.getString(R.string.text_mac_no) + " " + item?.machineno
//        var quantity = context.getString(R.string.text_amount) + " " + item?.sengemntNumber
//        var size = context.getString(R.string.text_size) + " " + item?.size
//        val textColor = ContextCompat.getColor(context, R.color.color_text_grey)
//        if (!TextUtils.isEmpty(item?.machinename)) {
//            var machineName = context.getString(R.string.text_mac_name) + " " + item?.machinename
//            helper.setText(
//                R.id.tvMachineNameDayPlayItem,
//                SpannableStrUtil.getColorSpannable(machineName, 4, machineName.length, textColor)
//            )
//        } else {
//            var machineName = context.getString(R.string.text_mac_name) + " "
//        }
//        helper.setText(
//            R.id.tvStyleNoDayPlayItem,
//            SpannableStrUtil.getColorSpannable(styleNo, 3, styleNo.length, textColor)
//        )
//        helper.setText(
//            R.id.tvColorDayPlayItem,
//            SpannableStrUtil.getColorSpannable(color, 3, color.length, textColor)
//        )
////        helper.setText(
////            R.id.tvMachineNoPlayItem,
////            SpannableStrUtil.getColorSpannable(machineNo, 5, machineNo.length, textColor)
////        )
//        helper.setText(
//            R.id.tvQuantityDayPlayItem,
//            SpannableStrUtil.getColorSpannable(quantity, 3, quantity.length, textColor)
//        )
//        helper.setText(
//            R.id.tvSizeDayPlayItem,
//            SpannableStrUtil.getColorSpannable(size, 3, size.length, textColor)
//        )
//
//        val ivHideShow = helper.getView<ImageView>(R.id.ivDayPlayShowHide)
//        val llPro = helper.getView<LinearLayout>(R.id.llProcDayPlayItem)
//        //for add view
//        if (item?.orderCraftprocessVersionList !== null) {
//            llPro.removeAllViews()
//            for (orderCraftprocess in item?.orderCraftprocessVersionList) {
//                val inflate = LayoutInflater.from(context)
//                    .inflate(R.layout.item_item_proc_day_produce_plan, null)
//                inflate.tvProcName.text = orderCraftprocess.procName
//                inflate.tvProcType.visibility = View.GONE
//                inflate.btnMore.visibility = View.GONE
//                if (!TextUtils.isEmpty(orderCraftprocess.baseWage)) {
//                    inflate.tvJcgj.text =
//                        context.getString(R.string.text_base_wage) + " " + orderCraftprocess.baseWage
//                }else{
//                    inflate.tvJcgj.text =
//                        context.getString(R.string.text_base_wage)
//                }
//                if (!TextUtils.isEmpty(orderCraftprocess.selfWage)) {
//                    inflate.tvCngj.text =
//                        context.getString(R.string.text_self_wage) + " " + orderCraftprocess.selfWage
//                }else{
//                    inflate.tvCngj.text =
//                        context.getString(R.string.text_self_wage)
//                }
//                if (!TextUtils.isEmpty(orderCraftprocess.standardValue)) {
//                    inflate.tvBzms.text =
//                        context.getString(R.string.text_stand_value) + " " + orderCraftprocess.standardValue
//                }else{
//                    inflate.tvBzms.text =
//                        context.getString(R.string.text_stand_value)
//                }
//                if (!TextUtils.isEmpty(orderCraftprocess.standardTime)) {
//                    inflate.tvBzmz.text =
//                        context.getString(R.string.text_stand_time) + " " + orderCraftprocess.standardTime
//                }else{
//                    inflate.tvBzmz.text =
//                        context.getString(R.string.text_stand_time)
//                }
//                if (!TextUtils.isEmpty(orderCraftprocess.ieccoefficient)) {
//                    inflate.tvIE.text =
//                        context.getString(R.string.text_ie) + " " + orderCraftprocess.ieccoefficient
//                }else{
//                    inflate.tvIE.text =
//                        context.getString(R.string.text_ie)
//                }
//                llPro.addView(inflate)
//            }
//        }
//
//        if (item?.show!!) {
//            ivHideShow.setImageResource(R.mipmap.icon_shengchanjihua_heqi)
//            llPro.visibility = View.VISIBLE
//        } else {
//            ivHideShow.setImageResource(R.mipmap.icon_shengchanjihua_zhankai)
//            llPro.visibility = View.GONE
//        }
//        helper.getView<LinearLayout>(R.id.llBtnDayPlayShowHide).setOnClickListener {
//            //展开收起
//            if (item?.show!!) {
//                item?.show = false
//            } else {
//                item?.show = true
//            }
//            notifyDataSetChanged()
//        }
    }
}

